package yf.mall.dao;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import yf.mall.entity.CashApplyEntity;
import yf.mall.vo.CashApplyVo;
import org.apache.ibatis.annotations.Mapper;
import com.yf.dao.BaseDao;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
/**
 * 提现申请表Dao
 *
 * 
 * 
 * @date Tue Sep 29 10:16:21 CST 2020
 */
@Mapper
public interface CashApplyDao extends BaseDao<CashApplyEntity> {

    List<CashApplyVo> findVo(CashApplyVo vo);

    CashApplyVo getVo(Long id);


    Long findByTime(String passTime,Long userId);

    BigDecimal findByUserId(@Param("userId") Long userId,@Param("identify")Integer identify);

    @Select("select  * from cash_apply where  app_no = #{orderNo}")
    CashApplyEntity findByNo(String busId);

    @Select("select * from  cash_apply where user_id = #{userId} order by id desc limit #{page},#{limit}")
    List<CashApplyEntity> findByUser(@Param("userId") Long userId, @Param("page") int page, @Param("limit") int limit);

    @Select("select * from cash_apply where user_id = #{userId} and TO_DAYS(#{date}) = TO_DAYS(crate_time)  limit 1")
    CashApplyEntity findByDay(@Param("userId") Long userId, @Param("date") Date date);

    //找到几天前审核的订单
    @Select("select * from cash_apply where status = #{status} and crate_time <= DATE_SUB(now(),INTERVAL #{day} DAY)")
    List<CashApplyEntity> findByDayBeforeAndStatus( @Param("day") Integer day,Integer status);
}
